Skip to content

Change RunDefaultContainerAndStopOnCleanup to use the interface testing.TB#48

Merged
oleg-nenashev merged 1 commit intowiremock:mainfrom
jordcarfetch:allow-benchmarks
May 4, 2025
Merged

Change RunDefaultContainerAndStopOnCleanup to use the interface testing.TB#48
oleg-nenashev merged 1 commit intowiremock:mainfrom
jordcarfetch:allow-benchmarks

Conversation

@jordcarfetch
Copy link
Copy Markdown
Contributor

@jordcarfetch jordcarfetch commented Apr 22, 2025

This allows test-containers to be used in benchmark setup code.
While it's generally recommended to isolate the code one is benchmarking, profiling the end to end logic of a handler can still reveal bottlenecks and extra memory allocations.

This change is backwards compatible, as *testing.T is an implementation of testing.TB.

References

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

This probably shouldn't require a version bump since these
functions will still accept a *testing.T as their argument.

This allows test-containers to be used in benchmark setup code
which can be useful when trying to benchmark http client code.
@jordcarfetch
Copy link
Copy Markdown
Contributor Author

jordcarfetch commented Apr 22, 2025

I have an in-mem caching http client I need to benchmark -- just the first request goes over the wire during setup. I could mock or inject at a more granular level, but then the profiling is less realistic.

Copy link
Copy Markdown
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on my machine, and thanks!
I plan some potentially planning to do some breaking changes in the next release too, so it should be fine in any case

@oleg-nenashev oleg-nenashev added the enhancement New feature or request label May 4, 2025
@oleg-nenashev oleg-nenashev changed the title change receivers to be of interface testing.TB Change RunDefaultContainerAndStopOnCleanup to use the interface testing.TB May 4, 2025
@oleg-nenashev oleg-nenashev merged commit 176d731 into wiremock:main May 4, 2025
2 checks passed
@jordcarfetch jordcarfetch deleted the allow-benchmarks branch May 16, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants